package 实现多线程;

public class 线程的相关控制3 {
    public static void main(String[] args) {
        ThreadDemo td1 = new ThreadDemo();
        ThreadDemo td2 = new ThreadDemo();
        td1.setName("关羽");
        td2.setName("张飞");
        /*设置主线程是刘备*/
        Thread.currentThread().setName("刘备");
        /*设置守护线程*/
        td1.setDaemon(true);
        td2.setDaemon(true);
        td1.start();
        td2.start();
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}
class ThreadDemo extends Thread{
    public void run(){
        for (int i = 0; i < 100; i++) {
            System.out.println(getName()+":"+i);
        }
    }
}